/**
 *	模块字段定义
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2024-07-19
 */


package com.framework.ACore;

import com.framerock.baselib.Rock;

import java.util.Map;

/**
 * 模块字段定义模型
 * */
public class ModuleFields {
    public static ModuleFields get()
    {
        return new ModuleFields();
    }

    public static int OPEN  = 1;
    public static int CLOSE = 0;

    public static int ALIGN_CENTER = 0;
    public static int ALIGN_LEFT = 1;
    public static int ALIGN_RIGHT = 2;

    //字段名称
    private String name = "";

    //字段名
    private String fields = "";

    //类型
    private String type = "varchar(50)";

    //默认值
    private String dev = "";

    //说明备注或者字段名称
    private String sm = "";

    //数据源
    private String data = "";

    //字段类型
    private String fieldstype = "";

    //属性
    private String attr = null;

    //默认值的
    private String devval = null;

    //设置文本框提示
    private String placeholder = null;

    private String gongshi = null;

    //字段说明
    private String zdsm = null;

    private String ftype = null;

    //是否搜索
    private int isss = -1;

    private int lens = -1;

    //是否必填
    private int isbt = -1;

    //是否只能
    private int isonly = -1;

    //是否排序
    private int ispx = -1;

    //编辑方式
    private int iseditlx = -1;

    //开启录入
    private int islu = -1;

    //对齐方式
    private int isalign = -1;

    //是否不加表单元素管理字段
    private int notelement = -1;

    //是否列表里
    private int islb = -1;

    private int iszs = -1;


    /**
     * 表单录入的placeholder内容
     * */
    public ModuleFields setPlaceholder(String placeholder) {
        this.placeholder = placeholder;
        return this;
    }

    /**
     * 字段名称
     * */
    public ModuleFields setName(String name) {
        this.name = name;
        return this;
    }

    /**
     * 字段名，字母组合
     * */
    public ModuleFields setFields(String fields) {
        this.fields = fields;
        return this;
    }

    /**
     * 字段类型 如varchar(100)
     * */
    public ModuleFields setType(String type) {
        this.type = type;
        return this;
    }

    /**
     * 字段的默认值
     * */
    public ModuleFields setDev(String dev) {
        this.dev = dev;
        return this;
    }

    /**
     * 字段说明
     * */
    public ModuleFields setSm(String sm) {
        this.sm = sm;
        return this;
    }

    /**
     * 数据源
     * */
    public ModuleFields setData(String data) {
        this.data = data;
        return this;
    }

    /**
     * 元素管理的类型，text,select等
     * */
    public ModuleFields setFieldstype(String fieldstype) {
        this.fieldstype = fieldstype;
        return this;
    }

    /**
     * 是否可搜索
     * */
    public ModuleFields setIsss(int isss) {
        this.isss = isss;
        return this;
    }

    /**
     * 字段属性如readonly
     * */
    public ModuleFields setAttr(String attr) {
        this.attr = attr;
        return this;
    }

    /**
     * 是否必填
     * */
    public ModuleFields setIsbt(int isbt) {
        this.isbt = isbt;
        return this;
    }

    /**
     * 列编辑类型：0|不开启(默认),1|任何人,2|仅管理员,3|仅超级管理员
     * */
    public ModuleFields setIseditlx(int iseditlx) {
        this.iseditlx = iseditlx;
        return this;
    }

    /**
     * 是否可录入
     * */
    public ModuleFields setIslu(int islu) {
        this.islu = islu;
        return this;
    }

    /**
     * 是否只读
     * */
    public ModuleFields setIsonly(int isonly) {
        this.isonly = isonly;
        return this;
    }

    /**
     * 是否排序
     * */
    public ModuleFields setIspx(int ispx) {
        this.ispx = ispx;
        return this;
    }

    /**
     * 列表对齐方式 0居中默认,1居左,2居右
     * */
    public ModuleFields setIsalign(int isalign) {
        this.isalign = isalign;
        return this;
    }

    /**
     * 不添加到模块字段里
     * */
    public ModuleFields setNotelement(int notelement) {
        this.notelement = notelement;
        return this;
    }

    /**
     * 是否列表页显示，默认显示
     * */
    public ModuleFields setIslb(int islb) {
        this.islb = islb;
        return this;
    }

    /**
     * 模块字段里面的默认值
     * */
    public ModuleFields setDevval(String devval) {
        this.devval = devval;
        return this;
    }

    /**
     * 字段分组名称
     * */
    public ModuleFields setFtype(String ftype) {
        this.ftype = ftype;
        return this;
    }

    /**
     * 长度
     * */
    public ModuleFields setLens(int lens) {
        this.lens = lens;
        return this;
    }

    /**
     * 字段说明，显示在录入页
     * */
    public ModuleFields setZdsm(String zdsm) {
        this.zdsm = zdsm;
        return this;
    }

    /**
     * 设置公式
     * */
    public ModuleFields setGongshi(String gongshi) {
        this.gongshi = gongshi;
        return this;
    }

    /**
     * 设置是否详情页展示
     * */
    public ModuleFields setIszs(int iszs) {
        this.iszs = iszs;
        return this;
    }



    /**
     * 获取模块信息
     * */
    public Map<String, String> getMap()
    {
        Map<String, String> da = Rock.getMap();
        da.put("fields", this.fields);
        da.put("type", this.type);
        da.put("dev", this.dev);
        String sm = this.name;
        if(!Rock.isEmpt(this.data))sm += "@"+this.data+"";
        da.put("sm", sm);
        if(!Rock.isEmpt(this.fieldstype))da.put("fieldstype", this.fieldstype);
        if(this.isss != -1)da.put("isss", this.isss+"");
        if(this.isbt != -1)da.put("isbt", this.isbt+"");
        if(this.isonly != -1)da.put("isonly", this.isonly+"");
        if(this.ispx != -1)da.put("ispx", this.ispx+"");
        if(this.iseditlx != -1)da.put("iseditlx", this.iseditlx+"");
        if(this.islu != -1)da.put("islu", this.islu+"");
        if(this.isalign != -1)da.put("isalign", this.isalign+"");
        if(this.notelement != -1)da.put("notelement", this.notelement+"");
        if(this.islb != -1)da.put("islb", this.islb+"");
        if(this.ispx != -1)da.put("ispx", this.ispx+"");
        if(this.lens != -1)da.put("lens", this.lens+"");
        if(this.iszs != -1)da.put("iszs", this.iszs+"");
        if(this.attr != null)da.put("attr", this.attr);
        if(this.devval != null)da.put("devval", this.devval);
        if(this.placeholder != null)da.put("placeholder", this.placeholder);
        if(this.zdsm != null)da.put("zdsm", this.zdsm);
        if(this.ftype != null)da.put("ftype", this.ftype);
        if(this.gongshi != null)da.put("gongshi", this.gongshi);
        return da;
    }

    /**
     * 获取默认的
     * */
    public Map<String, String> getDefMap()
    {
        Map<String, String> da = Rock.getMap(),das;
        da.put("fields", this.fields);
        da.put("type", this.type);
        da.put("name", this.name);
        da.put("fieldstype", this.fieldstype);
        da.put("data", this.data);
        da.put("dbtype", this.type);
        da.put("islb", "0");
        da.put("isbt", "0");
        da.put("isonly", "0");
        da.put("islu", "0");
        da.put("isss", "0");
        da.put("iseditlx", "0");
        da.put("isalign", "0");
        da.put("ispx", "0");
        da.put("iszs", "0");
        das = getMap();
        for (Map.Entry<String, String> entry : das.entrySet())
            da.put(entry.getKey(), entry.getValue());
        return da;
    }
}
